<?php

$productsPerRow = 2;
$productsPerPage = 4;

$sql = "SELECT pd_id, pd_name, pd_price, pd_image, pd_qty, c.cat_id
		FROM tbl_product pd, tbl_category c
		WHERE pd.cat_id = c.cat_id AND c.cat_name = 'showcase'
		ORDER BY pd_id";

$result     = dbQuery(getPagingQuery($sql, $productsPerPage));
$numProduct = dbNumRows($result);


?>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tbody>
	<?php 
		if ($numProduct == 0 ) 
		{
	?>	
		<tr>
			<td class="lt">
				<span class="heading">Product Gallery</span>
				<br>
				<span class="ylTxt">
					<strong>No products to showcase</strong>
				</span>
			</td>
		</tr>
	<?php
		}
		else
		{
	?>	
		<tr>
			<td class="lt">
				<span class="heading">Product Gallery</span>
				<br>
				<span class="ylTxt">
					<strong>Text for products</strong>
				</span>
			</td>
		</tr>
		
		<tr>
			<td class="lt padd20"></td>
		</tr>
		
	<?php
			$i = 0;
			while ($row = dbFetchAssoc($result)) 
			{
				extract($row);

				// format how we display the price
				$pd_price = displayAmount($pd_price);
	?>
	
	<?php
				if ($i % $productsPerRow == 0) 
				{
	?>
		<tr>
			<td class="lt">
				<table width="100%" border="0" cellpadding="1" cellspacing="0">
					<tbody>
						<tr>
	<?php
				}
	?>
						
							<td class="lt galleryBox">
								<table width="100%" border="0" cellspacing="0" cellpadding="1">
									<tbody>
										<tr>
											<td align="center" class="cm">
												<p class="img-pad" align="center">
													<img src="images/product/<?php echo $pd_image; ?>" alt width="139" height="80" class="img-brdr">
												</p>
											</td>
										</tr>
										<tr>
											<td class="cm"><?php echo $pd_price; ?></td>
										</tr>
									</tbody>
								</table>
							</td>
							
	<?php
				if ($i % $productsPerRow == 0) 
				{
	?>
							<td width="35" class="rt">
								<img src="<?php echo $tmplImagePath; ?>blank.gif" alt width="1" height="1">
							</td>
							
	<?php
				}
	?>


	<?php
				if ($i % $productsPerRow != 0) 
				{
	?>
						</tr>
						
						<tr>
							<td height="35" class="rt">
								<img src="<?php echo $tmplImagePath; ?>blank.gif" alt width="1" height="1">
							</td>
						</tr>
					</tbody>
				</table>
			</td>
		</tr>
	<?php
				}
	?>

	<?php
				$i += 1;
			}
		}
	?>
	</tbody>
</table>
